package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.CheckGroup;
import org.apache.ibatis.annotations.*;

/**
 * @author kcs
 * @date 2021/11/22
 * @TIME:23:58
 */
@Mapper
public interface CheckGroupMapper extends BaseMapper<CheckGroup> {

    //获取该id对应检查组包含的多个检查项ID
    @Select("select checkitem_id from t_checkgroup_checkitem where checkgroup_id = #{id}")
    int[] findCheckItemIdsByCheckGroupId(Integer id);

    //添加检查组对应检查项到关系表
    @Insert("insert into t_checkgroup_checkitem values (#{checkGroupId},#{checkitemId})")
    void add(@Param("checkitemId") Integer checkitemId, @Param("checkGroupId") Integer checkGroupId);

    //在关系表中删除该检查组和对应检查项的关系数据
    @Delete("delete from t_checkgroup_checkitem where checkgroup_id = #{checkGroupId}")
    void delete(Integer checkGroupId);
}
